  with TRtcFunction.Create(RtcFg) do
  begin
    FunctionName := 'SysCache';
    Group := RtcFg;
    OnExecute := Anon(
      procedure(Sender: TRtcConnection; Param: TRtcFunctionInfo; Result: TRtcValue)
      begin
          Result.astext :=gconfig.values[Param.asString['PARAMS']];
      end);
  end;

  with TRtcFunction.Create(RtcFg) do
  begin
    FunctionName := 'SysLog';
    Group := RtcFg;
    OnExecute := Anon(
      procedure(Sender: TRtcConnection; Param: TRtcFunctionInfo; Result: TRtcValue)
      begin
        syslog(Param.asString['PARAMS']);
      end);
  end;

  with TRtcFunction.Create(RtcFg) do
  begin
    FunctionName := 'SysDate';
    Group := RtcFg;
    OnExecute := Anon(
      procedure(Sender: TRtcConnection; Param: TRtcFunctionInfo; Result: TRtcValue)
      begin
       if Param.isnull['PARAMS'] then
         Result.asString := FormatDateTime('yyyy-mm-dd', Now)
       else if Param.istype['PARAMS'] = rtc_Array then
         if Param.asArray['PARAMS'].Count = 1 then
           Result.asString := FormatDateTime(Param.asarray['PARAMS'].asString[0], Now)
         else
           Result.asString := FormatDateTime(Param.asarray['PARAMS'].asString[0],
           StrToInt(Param.asarray['PARAMS'].asString[1]))
      end);
  end;

  with TRtcFunction.Create(RtcFg) do
  begin
    FunctionName := 'SysS2R';
    Group := RtcFg;
    OnExecute := Anon(
      procedure(Sender: TRtcConnection; Param: TRtcFunctionInfo; Result: TRtcValue)
      begin
         Result.asRecord := TRtcRecord.fromjson(Param.asstring['PARAMS']);
      end);
  end;

  with TRtcFunction.Create(RtcFg) do
  begin
    FunctionName := 'SysS2A';
    Group := RtcFg;
    OnExecute := Anon(
      procedure(Sender: TRtcConnection; Param: TRtcFunctionInfo; Result: TRtcValue)
      begin
         Result.asArray := TRtcArray.fromjson(Param.asstring['PARAMS']);
      end);
  end;

  with TRtcFunction.Create(RtcFg) do
  begin
    FunctionName := 'FileWrite';
    Group := RtcFg;
    OnExecute := Anon(
      procedure(Sender: TRtcConnection; Param: TRtcFunctionInfo; Result: TRtcValue)
      begin
         try
           write_file(Param.asArray['PARAM'].asString[1], Param.asArray['PARAM'].asString[0]);
           Result.asInteger := 1;
         except
           Result.asInteger := 0;
         end;
      end);
  end;

  with TRtcFunction.Create(RtcFg) do
  begin
    FunctionName := 'FileRead';
    Group := RtcFg;
    OnExecute := Anon(
      procedure(Sender: TRtcConnection; Param: TRtcFunctionInfo; Result: TRtcValue)
      begin
        Result.asString := read_file(Param.asString['PARAMS']);
      end);
  end;

  with TRtcFunction.Create(rtcfg) do
  begin
    FunctionName := 'dbvalue';
    Group := rtcfg;
    OnExecute := Anon(
      procedure(Sender: TRtcConnection; Param: TRtcFunctionInfo; Result: TRtcValue)
       var
        p: TRtcArray;
      begin
        if Param.Count > 1 then
          p := Param.asArray['PARAMS'];
        case Param.Count of
          1:
            Result.asValue := dbValue(Param.asString['PARAMS'], []);
          2:
            Result.asValue := dbValue(p[0], [p[1]]);
          3:
            Result.asValue := dbValue(p[0], [p[1], p[2]]);
          4:
            Result.asValue := dbValue(p[0], [p[1], p[2], p[3]]);
          5:
            Result.asValue := dbValue(p[0], [p[1], p[2], p[3], p[4]]);
          6:
            Result.asValue := dbValue(p[0], [p[1], p[2], p[3], p[4], p[5]]);
        end;
      end);
  end;

  with TRtcFunction.Create(rtcfg) do
  begin
    FunctionName := 'dbsql';
    Group := rtcfg;
    OnExecute := Anon(
      procedure(Sender: TRtcConnection; Param: TRtcFunctionInfo; Result: TRtcValue)
      var
        p: TRtcArray;
      begin
        if Param.Count > 1 then
          p := Param.asArray['PARAMS'];
        case Param.Count of
          1:
            Result.asValue := dbSql(Param.asString['PARAMS'], []);
          2:
            Result.asValue := dbSql(p[0], [p[1]]);
          3:
            Result.asValue := dbSql(p[0], [p[1], p[2]]);
          4:
            Result.asValue := dbSql(p[0], [p[1], p[2], p[3]]);
          5:
            Result.asValue := Dbsql(p[0], [p[1], p[2], p[3], p[4]]);
          6:
            Result.asValue := dbSql(p[0], [p[1], p[2], p[3], p[4], p[5]]);
        end;
      end);
  end;

  with TRtcFunction.Create(rtcfg) do
  begin
    FunctionName := 'dbjson';
    Group := rtcfg;
    OnExecute := Anon(
      procedure(Sender: TRtcConnection; Param: TRtcFunctionInfo; Result: TRtcValue)
      var
        p: TRtcArray;
      begin
        if Param.Count > 1 then
          p := Param.asArray['PARAMS'];
        case Param.Count of
          1:
            Result.asValue := dbJson(Param.asString['PARAMS'], []);
          2:
            Result.asValue := dbJson(p[0], [p[1]]);
          3:
            Result.asValue := dbJson(p[0], [p[1], p[2]]);
          4:
            Result.asValue := dbJson(p[0], [p[1], p[2], p[3]]);
          5:
            Result.asValue := dbJson(p[0], [p[1], p[2], p[3], p[4]]);
          6:
            Result.asValue := dbJson(p[0], [p[1], p[2], p[3], p[4], p[5]]);
        end;
      end);
  end;

 with TRtcFunction.Create(rtcfg) do
  begin
    FunctionName := 'dbqry';
    Group := rtcfg;
    OnExecute := Anon(
      procedure(Sender: TRtcConnection; Param: TRtcFunctionInfo; Result: TRtcValue)
      var
        p: TRtcArray;
      begin
        if Param.Count > 1 then
          p := Param.asArray['PARAMS'];
        case Param.Count of
          1:
            Result.asValue := dbJson(Param.asString['PARAMS'], []);
          2:
            Result.asValue := dbJson(p[0], [p[1]]);
          3:
            Result.asValue := dbJson(p[0], [p[1], p[2]]);
          4:
            Result.asValue := dbJson(p[0], [p[1], p[2], p[3]]);
          5:
            Result.asValue := dbJson(p[0], [p[1], p[2], p[3], p[4]]);
          6:
            Result.asValue := dbJson(p[0], [p[1], p[2], p[3], p[4], p[5]]);
        end;
      end);
  end;
  with TRtcFunction.Create(rtcfg) do
  begin
    FunctionName := 'dbbackup';
    Group := rtcfg;
    OnExecute := Anon(
      procedure(Sender: TRtcConnection; Param: TRtcFunctionInfo; Result: TRtcValue)
      begin
        dbbackup;
      end);
  end;
